package correiosInterface;

import correiosDados.Coordenada;

public class MapController {
	
	public static String buildMapContent(Coordenada center, String address){
		String content = new String();
		
		content = content.concat("<html>\r\n");
		content = content.concat("<head>\r\n");
		content = content.concat("<meta name=\"viewport\" content=\"initial-scale=1.0, user-scalable=no\" />\r\n");
		content = content.concat("<style type=\"text/css\">\r\n");
		content = content.concat("  html { height: 100% }\r\n");
		content = content.concat("  body { height: 100%; margin: 0px; padding: 0px }\r\n");
		content = content.concat("  #map_canvas { height: 100%; background-color: #666970; }\r\n");
		content = content.concat("</style>\r\n");
		content = content.concat("<script type=\"text/javascript\" src=\"http://maps.google.com/maps/api/js?sensor=false\">\r\n");
		content = content.concat("</script>\r\n");
		content = content.concat("<script type=\"text/javascript\">\r\n");
		content = content.concat("  function initialize() {\r\n");
		content = content.concat("    var latlng = new google.maps.LatLng(" + center.getLatitude() + ", " + center.getLongitude() + ");\r\n");
		content = content.concat("    var myOptions = {\r\n");
		content = content.concat("      zoom: 16,\r\n");
		content = content.concat("      center: latlng,\r\n");
		content = content.concat("      mapTypeId: google.maps.MapTypeId.ROADMAP,\r\n");
		content = content.concat("      mapTypeControl: false,\r\n");
		content = content.concat("      navigationControl: false,\r\n");
		content = content.concat("      streetViewControl: false,\r\n");
		content = content.concat("      backgroundColor: \"#666970\"\r\n");
		content = content.concat("    };\r\n");
		content = content.concat("    map = new google.maps.Map(document.getElementById(\"map_canvas\"),myOptions);\r\n");
		content = content.concat("    var marker1 = new google.maps.Marker({\r\n");
		content = content.concat("        position: new google.maps.LatLng(" + center.getLatitude() + "," + center.getLongitude() + "),\r\n");
		content = content.concat("        map: map\r\n");
		content = content.concat("    });\r\n");
		content = content.concat("    var contentString = '" + address + "'\r\n");
		content = content.concat("    var infowindow1 = new google.maps.InfoWindow({\r\n");
		content = content.concat("        content: contentString\r\n");
		content = content.concat("    });\r\n");
		content = content.concat("    infowindow1.open(map, marker1);\r\n");
		content = content.concat("    google.maps.event.addListener(marker1, 'click', function() {\r\n");
		content = content.concat("       infowindow1.open(map, marker1);\r\n");
		content = content.concat("    });\r\n");
		content = content.concat("  }\r\n");
		content = content.concat("</script>\r\n");
		content = content.concat("</head>\r\n");
		content = content.concat("<body onload=\"initialize()\">\r\n");
		content = content.concat("  <div id=\"map_canvas\" style=\"width:100%; height:100%\"></div>\r\n");
		content = content.concat("  <div style:visibility=\"hidden\" id=\"inv\"></div>\r\n");
		content = content.concat("</body>\r\n");
		content = content.concat("</html>\r\n");
		
		return content;
		
	}
	
}
